<?php
class Index_Model_Pagedata implements Index_Model_Mainable{
    
    private $index_data_getmenudata;
    private $index_data_getmoduledata;
    private $core_controller_csrftoken;
    private $index_data_addneworder;
    private $index_data_getallcategorydata;
    private $index_data_getsubcategorydata;
    private $index_data_sendmail;
    
    public function __construct() {
        $this->index_data_getmenudata = new Index_Data_Getmenudata;
        $this->index_data_getmoduledata = new Index_Data_Getmoduledata;
        $this->core_controller_csrftoken = new Core_Controller_Csrftoken;
        $this->index_data_getallcategorydata = new Index_Data_Getallcategory;
        $this->index_data_getsubcategorydata = new Index_Data_Subcategorydata;
        
    }
    
    public function main(array $variables = null){
        
        //var_dump($variables['post']);
        //die();
        if(isset($variables['post']['csrf_token']) && ($variables['post']['csrf_token'] == $_SESSION['csrf_token'])){
            $this->index_data_addneworder = new Index_Data_Addneworder;
            $this->index_data_addneworder->main($variables);
        }
        if(isset($_POST['form-email'])){
            $this->index_data_sendmail = new Index_Data_Sendemail;
            $this->index_data_sendmail->main($variables);
        }
        $page['menu_data'] = $this->index_data_getmenudata->main($variables);
        $page['category_data'] = $this->index_data_getallcategorydata->main($variables);
        $page['subcategory_data'] = $this->index_data_getsubcategorydata->main($variables);
        $page['content'] = $this->index_data_getmoduledata->main($variables);
        $page['csrf_token'] = $this->core_controller_csrftoken->main($variables);
        
        return $page;
    }
}
